package com.drpclub.gamebackend.common.config;

import com.drpclub.gamebackend.common.filter.AuthenticationFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author dongruipeng
 * @Descrpition
 * @date 2020year 05month07day  16:50:17
 */
@Configuration
public class FilterConfiguration {

    private final AuthenticationFilter auth;


    public FilterConfiguration(AuthenticationFilter auth) {
        this.auth = auth;
    }

    @Bean
    public FilterRegistrationBean<AuthenticationFilter> filterRegistrationBean() {
        FilterRegistrationBean<AuthenticationFilter> registBean = new FilterRegistrationBean<AuthenticationFilter>();
        registBean.setAsyncSupported(true);
        registBean.setFilter(auth);
        return registBean;
    }
}
